var ENV = {
APP_ROOT : '${contextPath}',
APP_FULL : '${fullContextPath}',
WebJarRoot : '${webJarRoot}',
CSRF_ParameterName : '${_csrf.parameterName}',
CSRF_Token : '${_csrf.token}',
};

var APP_ROOT = ENV.APP_ROOT;
var APP_FULL = ENV.APP_FULL;
var WebJarRoot = ENV.WebJarRoot;
var CSRF_ParameterName = ENV.CSRF_ParameterName;
var CSRF_Token = ENV.CSRF_Token;

var JAVASCRIPT_PATH = APP_ROOT+'/static/default/javascript';


<#list restServices as restService>
var RS${restService.name}='${contextPath}${restService.url}';
</#list>




var webjars = {
    versions: {
        <#list webJars as webJar>
            "${webJar.key}":"${webJar.value}",
        </#list>
    },
    path: function (webJarId, path) {
        console.error('The webjars.path() method of getting a WebJar path has been deprecated.  The RequireJS config in the ' + webJarId + ' WebJar may need to be updated.  Please file an issue: http://github.com/webjars/' + webJarId + '/issues/new');
        return ['${contextPath}${webJarRoot}' + webJarId + '/' + webjars.versions[webJarId] + '/' + path];
    }
};

var require = {
    callback: function () {
// Deprecated WebJars RequireJS plugin loader
        define('webjars', function () {
            return {
                load: function (name, req, onload, config) {
                    if (name.indexOf('.js') >= 0) {
                        console.warn('Detected a legacy file name (' + name + ') as the thing to load.  Loading via file name is no longer supported so the .js will be dropped in an effort to resolve the module name instead.');
                        name = name.replace('.js', '');
                    }
                    console.error('The webjars plugin loader (e.g. webjars!' + name + ') has been deprecated.  The RequireJS config in the ' + name + ' WebJar may need to be updated.  Please file an issue: http://github.com/webjars/webjars/issues/new');
                    req([name], function () {
                        onload();
                    });
                }
            }
        });

// All of the WebJar configs

    <#list json as m>
        requirejs.config(${m});
    </#list>


    requirejs.config({"paths":{"easy_web":[JAVASCRIPT_PATH+'/easy_web']},"shim":{"easy_web":['jquery', 'bootstrap', 'angular', 'ui-bootstrap-tpls']},"packages":[]});
    requirejs.config({"paths":{"easy_ui":[JAVASCRIPT_PATH+'/easy_ui']},"shim":{"easy_ui":['easy_web']},"packages":[]});
    }
};




var ezStaticResource = function(base,file){
return APP_ROOT+base+file;
};

var loadCSS = function (dir, file) {
var url = APP_ROOT + dir + file;
//console.log("css!"+url);
return "css!" + url;
};





if (!Array.prototype.indexOf) {

Array.prototype.indexOf = function (searchElement /*, fromIndex */) {


"use strict";

if (this === void 0 || this === null)
throw new TypeError();

var t = Object(this);
var len = t.length >>> 0;
if (len === 0)
return -1;

var n = 0;
if (arguments.length > 0) {
n = Number(arguments[1]);
if (n !== n)
n = 0;
else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0))
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}

if (n >= len)
return -1;

var k = n >= 0
? n
: Math.max(len - Math.abs(n), 0);

for (; k < len; k++) {
if (k in t && t[k] === searchElement)
return k;
}
return -1;
};

}


Array.prototype.insert = function (index, item) {
this.splice(index, 0, item);
};